from ronglian_sms_sdk import SmsSDK
from celery_tasks.main import app
# 写任务(函数)
# 任务必须要celery的实例对象装饰器task装饰
# 任务包的任务需要celery调用自检检查函数


@app.task
def celery_send_sms_code(mobile,sms_code):
    # 9.通过 容联云 发送短信
    # from ronglian_sms_sdk import SmsSDK
    accId = '8a216da8762cb4570176dc6980c73faf'
    accToken = '00d313c3df214478b14d9b99b8676dc9'
    appId = '8a216da8762cb4570176dc6981b03fb6'

    # 9.1 创建容联云 实例对象
    sdk = SmsSDK(accId, accToken, appId)

    tid = '1'  # 发送短信的模板，值 只能是 1
    mobile = '%s'%mobile  # '手机号1，手机号2' 给哪些手机号发送短信，只能是测试手机号
    datas = (sms_code, 5)  # ('变量1', '变量2')  涉及模板的变量
    # 您的验证码为{}，请于{}分钟内输入
    # 9.2 发送短信
    # resp = sdk.sendMessage(tid, mobile, datas)
    # print(resp)

    sdk.sendMessage(tid, mobile, datas)





